<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<c:url var="action" value="/menu/save.html" />
<form:form method="POST" commandName="menu" action="${action}" id="mainForm">
	<div id="layout-main-right-content">
		<div id="dialog-form" title="用户"> 
		<input type="hidden" name="id" id="id" value="${menu.id}" />
					<div class="yui3-g">
						<div class="yui3-u-1-6">
							<div class="content">
								<label for="code">代码</label>
							</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<input type="text" name="code" id="code"
									value="${menu.code}"
									class="text ui-widget-content ui-corner-all" />
								<form:errors path="code" cssClass="ui-state-error ui-corner-all" />
							</div>
						</div>
						<div class="yui3-u-1-6">
							<div class="content">
								<label for="name">名称</label>
							</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<input type="text" name="name" id="name"
									value="${menu.name}"
									class="text ui-widget-content ui-corner-all" />
							</div>
						</div>
					</div>
					<div class="yui3-g">
						<div class="yui3-u-1-6">
							<div class="content">
								<label for="url">地址</label>
							</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<input type="text" name="url" id="url" value="${menu.url}"
									class="text ui-widget-content ui-corner-all" />
							</div>
						</div>
						<div class="yui3-u-1-6">
							<div class="content">
								<label for="leaf">树叶-${menu.leaf}</label>
							</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<input type="checkbox" name="leaf" id="leaf" <c:if test="${menu.leaf}">checked="checked"</c:if> class="text ui-widget-content ui-corner-all" />
							</div>
						</div>
					</div>
					<div class="yui3-g">
						<div class="yui3-u-1-6">
							<div class="content">创建时间</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
									value="${menu.createTime}" />
							</div>
						</div>
						<div class="yui3-u-1-6">
							<div class="content">更新时间</div>
						</div>
						<div class="yui3-u-1-3">
							<div class="content">
								<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"
									value="${menu.updateTime}" />
							</div>
						</div>
					</div>
					<div class="yui3-g">
						<div class="yui3-u-1">
							<input type="button" id="save" value="保存" class="button_selector" />
							&nbsp;&nbsp;&nbsp;&nbsp; <input type="button" id="cancel"
								value="取消" class="button_selector"
								onclick="location.href='<c:url value="/menu/list.html"/>'" />
						</div>
					</div>		
		</div>	
		<div id="tabs">
			<table class="tablesorter" id="mainTable" cellspacing="1">
						<thead>
							<tr>
								<th class="header">ID</th>
								<th class="header">代码</th>
								<th class="header">名称</th>
								<th class="header">描述</th>
							</tr>
						</thead>
						<tbody>
							<c:set var="i" scope="page" value="0" />
							<c:forEach var="role" items="${menu.roles}">
								<tr class=<c:if test="${(i % 2) == 0}">"odd"</c:if>
									<c:if test="${(i % 2) == 1}">"even"</c:if>>
									<td>${role.id}</td>
									<td>${role.code}</td>
									<td>${role.name}</td>
									<td>${role.desc}</td>
								</tr>
								<c:set var="i" scope="page" value="${i+1}" />
							</c:forEach>
						</tbody>
			</table>			
		</div>
	</div>
</form:form>
<script type="text/javascript">
	jQuery(function($) {
		$("#birthDate").datepicker({
			dateFormat : 'yy-mm-dd',
			showOn : "button",
			buttonImage : "${ctx}/img/calendar.gif",
			buttonImageOnly : true
		});
		
		<c:if test="${not empty menu.roles}">
		$("#mainTable").tablesorter({
			sortList : [ [ 1, 0 ] ],
			widgets : [ 'zebra' ]
		}); 
		</c:if>

		$("#save").click(function() {
			$("#mainForm").submit();
		})
		
		$(".button_selector").button();

	});
</script>